//
//  HotTwoTableViewCell.m
//  Liuhe
//
//  Created by zr on 2018/8/20.
//  Copyright © 2018年 zr. All rights reserved.
//

#import "HotTwoTableViewCell.h"

@interface HotTwoTableViewCell ()

@property (nonatomic, weak)UIImageView * backImageView;
@property (nonatomic, weak)UIView * bottomView;
@property (nonatomic, weak)UILabel * titleLabel;

@end

@implementation HotTwoTableViewCell

- (void)setModel:(HotModel *)model{
    
    _model = model;
    
    NSArray * arr = model.images;
    
    NSURL * url = [NSURL URLWithString:arr.firstObject];
    [self.backImageView sd_setImageWithURL:url];
    
    self.titleLabel.text = model.title;
}


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    if ([super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self setupUI];
    }
    
    return self;
}


- (void)setupUI{
    
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    self.backgroundColor = WHITE_COLOR;
    
    UIImageView * backImageView = [UIImageView new];
    
    backImageView.backgroundColor = [UIColor redColor];
    
    self.backImageView = backImageView;
    
    [self.contentView addSubview:self.backImageView];
    
    
    UILabel * titleLabel = [UILabel new];
    
    titleLabel.textColor = BLACK_COLOR;
    titleLabel.font = [UIFont systemFontOfSize:15 * SCREENH6];
    
    self.titleLabel = titleLabel;
    
    [self.contentView addSubview:self.titleLabel];
}


- (void)layoutSubviews{
    
    [self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.contentView);
        make.trailing.mas_equalTo(self.contentView).offset(-5 * SCREENH6);
        make.width.mas_equalTo(75 * SCREENH6);
        make.height.mas_equalTo(61 * SCREENH6);
    }];
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self.contentView).offset(15 * SCREENH6);
        make.trailing.mas_equalTo(self.backImageView.mas_leading).offset(-7 * SCREENH6);
        make.top.mas_equalTo(self.backImageView);
    }];
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
